package pub.tbc.atps;


import lombok.extern.slf4j.Slf4j;
import pub.tbc.atps.collector.Collectors;
import pub.tbc.atps.initialize.HandlerInit;

import java.util.Arrays;

/**
 * @author tbc on 2016/11/10 21:06:59.
 */
@Slf4j
public class Bootstrap {
    //started parameter
    private static final String HANDLER_VALIDATOR = "handler.validator";
    private static final String HANDLER_EXECUTOR = "handler.executor";
    private static final String HANDLER_CACHE = "handler.cache";

    public static void main(String[] args) {
        D.startTime = System.currentTimeMillis();
        log.info("System starting... ");

        //
        Banner.printBanner();

        log.info("初始化配置文件...");
        initConfig();

        log.info("设置启动参数（启动参数的配置优先级高于配置文件）...");
        configStartParam(args);

        log.info("初始化Handler");
        HandlerInit.handlerInit();

        // 连接器开始监听MQ
        log.info("started monitor queue...");
        Collectors.monitor();
    }

    /**
     *
     */
    private static void initConfig() {

    }

    /**
     * @param args p
     */
    private static void configStartParam(String[] args) {
//        if (Objs.isEmpty(args)) return;
        Arrays.stream(args).forEach(it -> {
            if (it.startsWith(HANDLER_VALIDATOR)) {

            }
            if (it.startsWith(HANDLER_EXECUTOR)) {

            }
            if (it.startsWith(HANDLER_CACHE)) {

            }
        });
    }
}
